package folexpr.presentation;

import javax.swing.JPanel;
import java.awt.Frame;
import java.awt.BorderLayout;
import javax.swing.JDialog;
import javax.swing.JTextArea;
import java.awt.Font;
import java.awt.Insets;
import java.awt.Cursor;
import javax.swing.WindowConstants;
import java.awt.Dimension;

public class ParseErrorWindow extends JDialog {

	private static final long serialVersionUID = 1L;

	private JPanel jContentPane = null;

	private JTextArea jTextArea = null;

	/**
	 * @param owner
	 */
	public ParseErrorWindow(Frame owner, String message) {
		super(owner);
		initialize(message);
		this.setLocationRelativeTo(owner);
		this.setVisible(true);
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize(String message) {
		
		this.setSize(398, 400);
		this.setPreferredSize(new Dimension(350, 400));
		this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
		this.setAlwaysOnTop(true);
		this.setTitle("Parse Error");
		this.setContentPane(getJContentPane());
		this.getJTextArea().setText(this.getJTextArea().getText() + message);
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jContentPane = new JPanel();
			jContentPane.setLayout(new BorderLayout());
			jContentPane.add(getJTextArea(), BorderLayout.CENTER);
		}
		return jContentPane;
	}

	/**
	 * This method initializes jTextArea	
	 * 	
	 * @return javax.swing.JTextArea	
	 */
	private JTextArea getJTextArea() {
		if (jTextArea == null) {
			jTextArea = new JTextArea();
			
			jTextArea.setLineWrap(true);
			jTextArea.setFont(new Font("Serif", Font.PLAIN, 18));
			//jTextArea.setBackground(new Color(204, 255, 255));
			jTextArea.setEditable(false);
			jTextArea.setMargin(new Insets(5, 5, 5, 5));
			jTextArea.setOpaque(true);
			jTextArea.setWrapStyleWord(true);
			jTextArea.setText("Check the input theory or see the log tab for details.\n\n");
		}
		return jTextArea;
	}

}  //  @jve:decl-index=0:visual-constraint="10,10"
